<?php

//Startar sessionen och inkluderar filer
session_start();

require_once ('LoginController.php');
require_once('LoginView.php');
require_once ('LoginHandler.php');
require_once('..\Common\PageView.php');
require_once ('Database.php');
require_once('DBConfig.php');
require_once ('RegisterController.php');
require_once ('PageCompositionView.php');
require_once ('RegisterView.php');

class MasterController {
	public static function doControll(){
			
		//Skapar och initierar databasen
		$db = new Database();
		$db->Connect(new DBConfig());
		
		$registerView = new RegisterView();
		
		$pcv = new PageCompositionView();
		
		$registerController = new RegisterController();
		$loginHtml = $registerController->DoControl($db);
			
		$loginController = new LoginController();
		$registerHtml = $loginController->DoControll($db);
		
		$html =$pcv->merge($loginHtml, $registerHtml);
		
		$pageView = new \Common\PageView();
		
		$title = "Login";
		
		//Stänger databasen
		$db->Close();
		
		return $pageView->GetHTMLPage($title, $html); 
	}
}
echo MasterController::doControll();

